package searcher;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 返回搜索结果的集合
 * @author aleck
 *
 */
public class HitSet implements Iterable<Hit>{
	private List<Hit> hits = new ArrayList<Hit>();
	
	public int size() {
		return hits.size();
	}
	
	public List<Hit> getHits(int beginIndex, int count) {
		List<Hit> ret = new ArrayList<Hit>();
		for (int i = beginIndex; i < hits.size() && i - beginIndex < count; i++)
			ret.add(hits.get(i));
		return ret;
	}
	
	public void addHit(Hit hit) {
		hits.add(hit);
	}
	
	public void clear() {
		hits.clear();
	}

	@Override
	public Iterator<Hit> iterator() {
		return hits.iterator();
	}
}
